﻿using Nop.Core;
using Nop.Core.Domain.Orders;
using Nop.Services.Catalog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Nop.Services.Stores;
namespace Nop.Web.Models.Catalog
{
    [Serializable]
    public class ReserveCarModel
    {
        public int ProductVariantId { get; set; }
        public string Attributes { get; set; }
        public int Quantity { get; set; }
        public decimal CustomerEnteredPrice { get; set; }
        public static List<ShoppingCartItem> ConvertToShoppingCarItem(ReserveCarModel reserveCarModel, IProductService productService, IWorkContext workContext, IStoreService storeservice)
        {
            ShoppingCartItem result = new ShoppingCartItem();
            result.ProductVariantId = reserveCarModel.ProductVariantId;
            result.ProductVariant = productService.GetProductVariantById(reserveCarModel.ProductVariantId);
            result.Quantity = reserveCarModel.Quantity;
            result.ShoppingCartType = ShoppingCartType.ShoppingCart;
            result.AttributesXml = reserveCarModel.Attributes;
            result.CustomerEnteredPrice = reserveCarModel.CustomerEnteredPrice;
            result.Customer = workContext.CurrentCustomer;
            result.CustomerId = workContext.CurrentCustomer.Id;
            result.ProductVariant.Product = productService.GetProductById(result.ProductVariant.ProductId);
            result.ProductVariant.Product.Store = storeservice.GetStoreById(result.ProductVariant.Product.StoreId);
            List<ShoppingCartItem> resulrlist = new List<ShoppingCartItem>() { result };
            return resulrlist;
        }
    }
}